#!/bin/sh

#
# android_arm64-v8a_manaager 任务:
# 1 定义android的arm64-v8a有关的变量:
# host,arch,arm64-v8a的交叉编译工具位置.
# 2 如果有必要合并各个arch的库
#

# +++ Description Start +++
# 编译sdl2+ffmpeg
# 整体编译时间
# === Description End ===

# +++ 变量声明 Start+++
export g_arch="x86_64"
export g_host="x86_64-apple-darwin"
export g_cc="xcrun -sdk macosx clang -target ${g_arch}-${vendor}-macos${g_minSdkVersion}"

# 当前脚本的架构目录
export g_scriptArchDir=${g_scriptPlatformDir}/${g_arch}
# 当前Build的架构目录
export g_buildArchDir=${g_buildPlatformDir}/${g_arch}
# 输出目录
export g_outputArchDir=${g_outputPlatformDir}/${g_arch}

# 环境变量
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"



main () {
    echo "+++ Build for ${g_platform} with ${g_arch} Start +++"

    _libArray=$(yq '.libArray.* | key' $g_projectDir/config.yml)
    libArray=($_libArray)


    declare -i length=${#libArray[@]}
    echo "length is: $length"
    for ((i = 0; i < ${length}; i++)); do
        libName=${libArray[i]}
        libVersion=$(yq ".libArray.$libName.version" $g_configFile)
        lib=$libName-$libVersion
        flag=$(yq ".libArray.$libName.action" $g_configFile)

        echo "lib:${lib},flag:${flag}"
        if [[ "${flag}" == $COMPILE_ACTION_CONFIGURE || "${flag}" == $COMPILE_ACTION_MAKE || "${flag}" == $COMPILE_ACTION_CONFIGURE_MAKE ]]; then
            # 导入环境变量
            . ${g_scriptArchDir}/${g_platform}_${g_arch}_${lib}.sh 
            # 执行脚本编译.
            . ${SCRITP_ROOT_DIR}/common/CommonBuildLib.sh ${flag}
        fi
    done

    

    echo "=== Build for ${g_platform} with ${g_arch} End ===\n\n\n"
}

main





